package test2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Date;

public class MyInvocationHandler implements InvocationHandler {
    //为谁增强
    private Object who;

    public MyInvocationHandler(Object who) {
        this.who = who;
    }

    @Override
//  proxy动态代理对象，method方法，args即方法的参数
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("顺丰快递收件-------------快递代码");

    /**
    *  对who对象invoke调用method方法，并传入args方法----------核心
    */
        Date getDate = (Date) method.invoke(who,args);

        System.out.println("顺丰快递已送达-----------快递代码" + getDate);
        return null;
    }
}
